package br.iars.model.entity;

import java.util.List;

import javax.persistence.AttributeOverride;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name = "context")
@AttributeOverride(name = "id", column = @Column(name = "context_id"))
public class Context extends GenericEntity<Long> {

	private static final long serialVersionUID = -3981920809491046558L;

	@Column(name = "company_name", length = 100, nullable = false)
	private String companyName;

	@Column(name = "system_name", length = 100, nullable = false)
	private String systemName;

	@Column(name = "min_rate", nullable = false)
	private Float minRate;

	@Column(name = "max_rate", nullable = false)
	private Float maxRate;

	@Enumerated(EnumType.STRING)
	@Column(name = "rate_type", length = 10, nullable = false)	
	private RateType rateType;

	@OneToMany(mappedBy = "context", fetch = FetchType.LAZY, cascade = { CascadeType.ALL })
	private List<Item> itens;

	public Context() {
		super();
	}

	public Context(Long id) {
		super(id);
	}

	public Context(String companyName, String systemName) {
		super();
		this.companyName = companyName;
		this.systemName = systemName;
	}

	public Context(String companyName, String systemName, Float minRate, Float maxRate, RateType rateType) {
		super();
		this.companyName = companyName;
		this.systemName = systemName;
		this.minRate = minRate;
		this.maxRate = maxRate;
		this.rateType = rateType;
	}

	public String getCompanyName() {
		return companyName;
	}

	public void setCompanyName(String companyName) {
		this.companyName = companyName;
	}

	public String getSystemName() {
		return systemName;
	}

	public void setSystemName(String systemName) {
		this.systemName = systemName;
	}

	public List<Item> getItens() {
		return itens;
	}

	public void setItens(List<Item> itens) {
		this.itens = itens;
	}

	public Float getMinRate() {
		return minRate;
	}

	public void setMinRate(Float minRate) {
		this.minRate = minRate;
	}

	public Float getMaxRate() {
		return maxRate;
	}

	public void setMaxRate(Float maxRate) {
		this.maxRate = maxRate;
	}

	public RateType getRateType() {
		return rateType;
	}

	public void setRateType(RateType rateType) {
		this.rateType = rateType;
	}

	public String toString() {
		return "Context [companyName=" + companyName + ", systemName=" + systemName + ", itens=" + itens + "]";
	}

}
